import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-11-12
 * Time: 10:58
 */
public class Demo3 {
    public static void main(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("./test.txt")) {
            //一次写入一个字节
            outputStream.write(97);
            outputStream.write(98);
            outputStream.write(99);

            //一次写入多个字节
            byte[] bytes = {65,66,67};
            outputStream.write(bytes);

            //从指定位置开始读取存储到文件中,从数组下标为 1，开始读取两个字节写入
            byte[] byte1 = {68,69,71};
            outputStream.write(byte1,1,2);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
